//
//  UIBarButtonItem+Extension.m
//  QQ空间
//
//  Created by zhangping on 16/1/30.
//  Copyright © 2016年 zhangping. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

/**
 *  快速创建UIBarButtonItem
 *  @param imageName 普通图片名称
 *  @return 带按钮的UIBarButtonItem
 */
+ (instancetype)itemWithImageName:(NSString *)imageName {
    NSString *highlightedImageName = [NSString stringWithFormat:@"%@_highlighted", imageName];
    
    UIButton *mapButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [mapButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [mapButton setImage:[UIImage imageNamed:highlightedImageName] forState:UIControlStateHighlighted];
    [mapButton sizeToFit];
    
    return [[UIBarButtonItem alloc] initWithCustomView:mapButton];
}
@end
